﻿using UnityEngine;
using System.Collections;

public class AlterneElev : MonoBehaviour 
{
	public GameObject player;
	public bool noElev;
	public GameObject meuElev;

	void OnTriggerEnter2D (Collider2D other)
	{
		if(other.gameObject.tag == "Player")
		{
			noElev = true;
		}
	}
	void OnTriggerExit2D (Collider2D other)
	{
		if(other.gameObject.tag == "Player")
		{
			noElev = false;
		}
	}
	void OnTriggerStay2D(Collider2D other)
	{ 
		if(other.gameObject.tag == "Player" && meuElev.GetComponent<Elevador>().open)
		{
			if(Input.GetKey(KeyCode.W))
			{		
					player.GetComponent<Player>().enterElev = true;
			}
			if( Input.GetKey(KeyCode.S))
			{
				player.GetComponent<Player>().enterElev = false;
			}
		}
	}
}
